package com.example.lenovo.mvp_demo.home.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.lenovo.mvp_demo.R;
import com.example.lenovo.mvp_demo.home.contract.HomeContract;
import com.example.lenovo.mvp_demo.home.presenter.HomePresenter;

public class MainActivity extends Activity implements View.OnClickListener,HomeContract.View{

    private Button mBt_data;
    private HomeContract.Presenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init_view();
        init_listener();
        init_presenter();
    }


    private void init_view() {
        mBt_data = findViewById(R.id.bt_data);
    }

    private void init_listener() {
        mBt_data.setOnClickListener(this);
    }


    private void init_presenter() {
        new HomePresenter(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId())
        {
            case R.id.bt_data:

                mPresenter.getWeather("李阳");


                 break;
        }
    }

    @Override
    public void showProgress() {
        Toast.makeText(this,"开始",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void dimissProgress() {
        Toast.makeText(this,"结束",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showMessage(String msg) {
    }

    @Override
    public void setPresenter(HomeContract.Presenter presenter) {
        mPresenter=presenter;
    }

    @Override
    public void showWeatherStr(String msg) {
        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
    }


}
